package com.leyou.order.listener;

import com.leyou.common.constants.MQConstants;
import com.leyou.order.service.OrderService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 短信监听类
 */
@Component
public class OrderListener {
    @Autowired
    private OrderService orderService;

    /**
     * 生成订单
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = MQConstants.Queue.SKU_SECKILL_QUEUE),
            exchange = @Exchange(name = MQConstants.Exchange.SECKILL_EXCHANGE_NAME, type = ExchangeTypes.TOPIC),
            key = MQConstants.RoutingKey.SKU_SECKILL_KEY
    ))
    public void createSkuSeckillOrder(Map<String, Object> map) {
        orderService.createSkuSeckillOrder(map);
    }

}
